home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news3.noc.netcom.net!zdc!zippo!usenet
- From: txwang@public.sta.net.cn (Wang)
- Subject: Re: pInt = new int [987654321L], what will ha
- X-Newsreader: Forte Free Agent 1.0.82
- Sender: usenet@news.zippo.com
- Nntp-Posting-Host: ts1-15.sta.net.cn
- Organization: No Organization
- Message-ID: <DM9z8w.4Fz@news.zippo.com>
- References: <Pine.SOL.3.91.960203215559.25805E-100000@hamlet.uncg.edu> <31146e4c.197257088@nntp.ix.netcom.com> <Pine.SOL.3.91.960204100529.12786A-100000@hamlet.uncg.edu>
- Date: Sun, 4 Feb 1996 23:42:54 GMT
-
- "QIAN . ZHONG" <q_zhong@hamlet.uncg.edu> wrote:
-
- | On Sun, 4 Feb 1996, Mike Rubenstein wrote:
-
- | > "QIAN . ZHONG" <q_zhong@hamlet.uncg.edu> wrote:
- | >
- | > >
- | > > Hi, folks:
- | > >
- | > > Here is a question about new, the following is my code:
- | > >
- | > > int main(void)
- | > > {
- | > > int *pInt;
- | > > long Block = 987654321L;
- | > >
- | > > pInt = new int[Block];
- | > > if(pInt == NULL) dosomething();
- | > > }
- | > >
- | > > My problem is when I compile the program for DOS under large memory
- | > > model, above new nerve return NULL, I guess compiler convert
- | > >
- | > > new int[987654321L] --- convert --> new int[ ACONST]
- | > > where ACONST = 0xffff , or ACONST = 0x7fff, am I right ?
- | > > Is this a DOS thing ? or a C++ thing ? Is this portable ?
- | >
- | > More likely the system just doesn't have 987 meg free memory, so it
- | > can't do the allocation. Newer compilers will throw an exception, but
- | > older ones simply return the null pointer.
- | >
- | >
- | > Michael M Rubenstein
- | >
- | >
- | Hi, Michael:
-
- | Thanks for your message, my real problem is the compiler will not return a
- | null pointer, even if I set_new_handler(0);
-
- | I am confused. Please help me again. I use BC++ 4.0.
-
- | Qian
-
- In DOS real mode, 987654321L may be converted to an unsigned int:
-
- (unsigned int)987654321L == 26801
-
- So, you are allocating 26801 * sizeof(int) == 52602 bytes of memory.
- If you still have plenty of memory, you'll get a good pointer.
-
- --
- Wang TianXing
-
-
-